package org.openea.eap.module.obpm.model.custsql.vo;

import org.openbpm.base.core.util.StringUtil;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;


public class SqlSearchVO
        implements Serializable {
    private static final long serialVersionUID = 1L;

    private String name;  //字段
    private String con;   //关系
    private String val;   //值
    private String val2;  //值2，用于范围inRange
    private String type;  //字段类型, text/number/date
    private String andOr = "and";
    private String bracket = "";  //括号？
    private Integer isInit;
    private Integer isGroup;
    private Integer isSystem;

    private static Map<String, String> mapCon = new HashMap();
    static{
        mapCon.put("equals","=");
        mapCon.put("notEqual","<>");
        mapCon.put("contains","like");
        mapCon.put("notContains","not like");
        mapCon.put("startsWith","llike");
        mapCon.put("endsWith","rlike");
        mapCon.put("lessThan","<");
        mapCon.put("lessThanOrEqual","<=");
        mapCon.put("greaterThan",">");
        mapCon.put("greaterThanOrEqual",">=");
        mapCon.put("inRange","between");
        // for ag-grid
        // equals/notEqual   （text/number/date)
        // contains/notContains/startsWith/endsWith (text)
        // lessThan/lessThanOrEqual/greaterThan/greaterThanOrEqual  (number/date)
        // inRange (number, date)
    }
    public static String convertCon(String con){
        if(mapCon.containsKey(con)){
            return  mapCon.get(con);
        }
        return con;
    }

    public SqlSearchVO() {
    }


    public SqlSearchVO(String name, String con, String val) {
        this.name = name;
        this.con = con;
        this.val = val;
    }

    public String getAndOr() {
        if (StringUtil.isEmpty(this.andOr)) {
            return "and";
        }
        return this.andOr;
    }

    public String getBracket() {
        if (StringUtil.isEmpty(this.bracket)) {
            return "";
        }
        return this.bracket;
    }


    public String getName() {
        return this.name;
    }


    public void setName(String name) {
        this.name = name;
    }


    public String getCon() {
        return this.con;
    }


    public void setCon(String con) {
        this.con = con;
    }


    public String getVal() {
        return this.val;
    }


    public void setVal(String val) {
        this.val = val;
    }


    public Integer getIsInit() {
        return this.isInit;
    }


    public void setIsInit(Integer isInit) {
        this.isInit = isInit;
    }

    public Integer getIsSystem() {
        return isSystem;
    }

    public void setIsSystem(Integer isSystem) {
        this.isSystem = isSystem;
    }

    public Integer getIsGroup() {
        return this.isGroup;
    }


    public void setIsGroup(Integer isGroup) {
        this.isGroup = isGroup;
    }


    public void setAndOr(String andOr) {
        this.andOr = andOr;
    }


    public void setBracket(String bracket) {
        this.bracket = bracket;
    }

    public String getVal2() {
        return val2;
    }

    public void setVal2(String val2) {
        this.val2 = val2;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }
}
